// 鼠标点击后返回到顶部
var stick = document.getElementById("footer-stick");
stick.onclick = function() {
    //返回到的是顶端
    $('html,body').stop().animate({ scrollTop: 0 });
}
kdj();
    function kdj(){

        var pa = window.location.search;
        var data = pa.match(/title=(.*)/)[1];
        console.log(data);
        var title = decodeURI(decodeURI(data));
        $('.ha-zt').text(title+'优惠券');
        var id = pa.match(/\d/)[0];
        console.log(id)
        $.ajax ({
            type:'get',
            data:{
                couponid:id
            },
            url:'http://193.112.55.79:9090/api/getcouponproduct',
            dataType:'json',
            success:function(res){
                console.log(res);
                template.config("escape", false);
                var htmlStr =  template('kdjyhq',res); 
                $('.content').html(htmlStr);
                var arr = [];
                // console.log($('.yhq-tp'));
                $.each($('.yhq-tp').children(),function(index,val){
                    var name =  {alt:'',pid: index,src:$(this).attr('src'),thumb:''};
                    arr.push(name);
                })
                $('.content').on('click','.yhq',function(){
                    // console.log($(this).index());
                    var photosJSON = {
                        title: "优惠卷图片",
                        id: "photo",
                        start: $(this).index(),
                        data: arr
                    }
                    layer.photos({
                        photos: photosJSON, 
                        anim: 5 
                    });
                })
            }
        })
    }
    